﻿using System.Windows;
using Ops.Mpc.States;
using Ops.Mpc.ExampleApplication.ExampleService;
using Ops.Mpc.Ioc;
using Ops.Mpc.Ioc.MessageBoxServices;

namespace Ops.Mpc.ExampleApplication.DataPaging.Actions
{
    public class CopyToClipboardStateAction : StateAction
    {
        protected override void OnExecute(object context)
        {
            Person person = context as Person;
            Clipboard.SetText(person.LastNameFirstName);

            IMessageBoxService iMessageBoxService = IocServiceLocator.Get<IMessageBoxService>();

            if (iMessageBoxService == null)
                MessageBox.Show("Person copied to clipboard");
            else
                IocServiceLocator.Get<IMessageBoxService>().Show(string.Format("{0} copied to clipboard",person.LastNameFirstName),"Success",MessageBoxButton.OK);

            this.Finish();
        }
    }
}
